﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Streambolics.Data
{
    public class DataTableColumn
    {
        private string _Name;
        private string _ExpectedType;
        private string _CurrentType;

   
        public DataTableColumn (string aName)
        {
            _Name = aName;
        }

        public void SetExpectedType (string aType)
        {
            _ExpectedType = aType;
        }

        public void SetCurrentType (string aType)
        {
            _CurrentType = aType;
        }

        public string Name
        {
            get
            {
                return this._Name;
            }
        }

       

        private void AddDescription (StringBuilder aBuilder, bool aComma)
        {
            if (aComma)
            {
                aBuilder.Append (",");
            }
            aBuilder.Append (this._Name);
            aBuilder.Append (" ");
            aBuilder.Append (this._ExpectedType);
        }

        public bool BuildAlterStatement (StringBuilder aBuilder, bool aComma)
        {
            if (!String.IsNullOrEmpty(this._ExpectedType) && !String.IsNullOrEmpty (this._CurrentType) && this._ExpectedType != this._CurrentType)
            {
                AddDescription (aBuilder, aComma);
                return true;
            }
            return false;
        }

        public bool BuildAddStatement (StringBuilder aBuilder, bool aComma)
        {
            if (!String.IsNullOrEmpty(this._ExpectedType) && String.IsNullOrEmpty (this._CurrentType))
            {
                AddDescription (aBuilder, aComma);
                return true;
            }
            return false;
        }

    }
}
